//Mon 21 Dec 2009 12:51:30 AM CST 
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class StreetWalking
{
public:
	long long minTime(int x, int y, int WalkTime, int SneakTime)
	{
		long long X =  x;
		long long Y =  y;
		long long walkTime = WalkTime;
		long long sneakTime = SneakTime;
		return pathcost(X,Y,walkTime,sneakTime);
	}
	long long pathcost(long long x, long long y, long long walkTime, long long sneakTime)
	{
		if(x == 0 && y == 0) return 0;
		if(x == 0) 
		{
			if(y%2 == 0) return min(walkTime, sneakTime) * y;
			return walkTime+min(walkTime, sneakTime)*(y-1);
		}
		if(y == 0)
		{
			if(x%2 == 0) return min(walkTime, sneakTime) * x;
			return walkTime+min(walkTime, sneakTime)*(x-1);
		}
		long long ret = (x+y)*max(walkTime, sneakTime);
		ret = min(ret, sneakTime+pathcost(x-1,y+1,walkTime,sneakTime));
		ret = min(ret, walkTime+pathcost(x-1,y,walkTime,sneakTime));
		ret = min(ret, sneakTime+pathcost(x-1,y-1,walkTime,sneakTime));
		ret = min(ret, walkTime+pathcost(x,y-1,walkTime,sneakTime));
		return ret;
	}
};
//TLE, but it still works well.
